import React from "react";
import { BrowserRouter as Router, Route, Redirect } from "react-router-dom";

// 导入 路由配置页
import Layout from "./pages/Layout";
import Map from "./pages/Map";
import CityList from "./pages/CityList";
import HouseDetail from "./pages/HouseDetail";
import Login from "./pages/Login";
import Registe from "./pages/Registe";
import Favorite from "./pages/Favorite";

// 发布房源组件
import Rent from './pages/Rent'
import RentAdd from './pages/Rent/Add'
import RentSearch from './pages/Rent/Search'

// 导入鉴权路由组件
import AuthRoute from "./components/AuthRoute";

function App() {
  return (
    <Router>
      <div className="App">
        {/* 配置路由 */}
        {/* 配置默认路由 */}
        <Route
          path="/"
          exact
          render={() => <Redirect to="/layout"></Redirect>}
        ></Route>
        {/* 配置 父路由 内部包含底部导航栏路由 */}
        <Route path="/layout" component={Layout}></Route>
        <AuthRoute path="/map" component={Map}></AuthRoute>
        <Route path="/citylist" component={CityList}></Route>
        <Route path="/favorite" component={Favorite}></Route>

        {/* 配置房屋详情路由 */}
        <Route path="/housedetail/:id" component={HouseDetail}></Route>
        {/* 配置登录/注册页面路由 */}
        <Route path="/login" component={Login}></Route>
        <Route path="/registe" component={Registe}></Route>

        {/* 配置登录后，才能访问的页面 */}
        <AuthRoute exact path="/rent" component={Rent} />
        <AuthRoute path="/rent/add" component={RentAdd} />
        <AuthRoute path="/rent/search" component={RentSearch} />
      </div>
    </Router>
  );
}

export default App;
